#include <Windows.h>

#include "XMLParser.h"

#include "XMLElement.h"

#include "MemberFunctionPointer.h"
#include "ICallDispatcher.h"
#include "FunctionContainer.h"

using namespace XMLSAX::Common;
using namespace XMLSAX::Core;

class test: public FunctionContainer<test>
{
public:
	test()
	{
		MemberFunctionPointer<test> *aCallbackFunction = new MemberFunctionPointer<test>(this, &test::testmethod);
		this->AddCallbackFunction(L"position", aCallbackFunction);
	}

	void testmethod(XMLElement *element)
	{
		OutputDebugString(L"\ntest function called.\n");
#ifdef _DEBUG
		element->printElement();
#endif
		OutputDebugString(L"\n\n");
	}
};

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	ICallDispatcher *testDispatcher = new test();

	XMLParser *pParser = new XMLParser();

	pParser->SetCallDispatcher(testDispatcher);
	pParser->ParseDocument(L"model.xml");

	delete testDispatcher;
	delete pParser;

	CoUninitialize();

	return 0;
}